package com.wuxiaofan.order.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.order.entity.OrderItem;
import com.wuxiaofan.order.entity.custom.OrderItemCustom;
import com.wuxiaofan.order.mapper.OrderItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.order.client.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class OrderItemService {
    @Autowired
    private OrderItemMapper omsOrderItemMapper;
    @Resource
    private Idgenerator idgenerator;
    public OrderItem findById(String id){
        return omsOrderItemMapper.selectById(id);
    }

    public OrderItemCustom findCountByMap(Map paraMap){
        return omsOrderItemMapper.findCountByMap(paraMap);
    }

    public OrderItemCustom findGroupByMap(Map paraMap){
        return omsOrderItemMapper.findGroupByMap(paraMap);
    }

    public List<OrderItemCustom> findByMap(Map paraMap){
        return omsOrderItemMapper.findByMap(paraMap);
    }

    public Page<OrderItemCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(omsOrderItemMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        omsOrderItemMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        omsOrderItemMapper.deleteById(id);
    }

    public OrderItem save(OrderItem omsOrderItem){
        omsOrderItem.setId(idgenerator.getId());
        omsOrderItemMapper.insert(omsOrderItem);
        return omsOrderItem;
    }

}
